package com.sskj.xgja.market;

import com.sskj.xgja.BasePresenter;
import com.sskj.base.utils.RxUtils;
import com.sskj.xgja.api.Api;
import com.sskj.xgja.api.ApiObserver;
import com.sskj.xgja.market.bean.Stock;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/03/21
 */
class ChartPresenter extends BasePresenter<ChartFragment> {

    public void getStock(String code, String goodsType, boolean showLoading) {
        Api.getInstance().stockData(code, goodsType)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<List<Stock>>(this, showLoading) {
                    @Override
                    public void onSuccess(List<Stock> data) {
                        mView.setChart(data, false);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        mView.setChart(null, false);
                    }
                });
    }
}
